//============================================================================
// Name        : ThreadingPatternGenomAnalyser.h
// Author      : Anthea Neums, Jonas Halbach
//			   :
// Description : This Class starts a defined number of Threads to solve the pattern genom matchng problem.
//============================================================================

#ifndef THREADING_PATTERNGENOMANALYSER_H_
#define THREADING_PATTERNGENOMANALYSER_H_

#include <stdlib.h>
#include <iostream>
#include <list>
#include <thread>
#include <functional>

#include "Found.h"
#include "FileReader.h"
#include "PatternGenomAnalyser.h"
#include "PatternGenomAnalyserThreadStarter.h"

namespace algorithm
{

	typedef std::list<Found *> List;

	class ThreadingPatternGenomAnalyser
	{
	public:
		ThreadingPatternGenomAnalyser(char *patternSource, char *genomSource, int wordlength, int threadCount);
		virtual ~ThreadingPatternGenomAnalyser();

	/**
	* This Method starts some threads to match the pattern and the genom.
	*/
		void findSimilarStrings();

		/**
		* This Method prints the Vector of the founded matches and adds "Ergebnisliste"
		* at the front and "Ende Ergebnisse" after printing the information about the
		* founds.
		*/
		void printFounds();

		/*
		* Getting a list of founds which stores the founded matches.
		*/
		std::list<Found *> *getFounds();

		

	private:
		// This vector stores all ThreadStarter Objects which are used to start the Threads which match the pattern and the genom
		vector<PatternGenomAnalyserThreadStarter *> threadStarterVector;
		//this list stores all threads
		list<thread *> threadList;
		//this list stores all the founds which are found by the PatternGenomMatchter
		std::list<Found *> *founds;
		void printMatches();
		const int wordlength;
		const int threadCount;
		FileReader *genomReader;
		FileReader *patternReader;
		list<PatternGenomAnalyser> patternGenomAnalyserList;

	};
}
#endif